
var urlService = "http://124.222.147.63:9555/";
// var urlService = "http://localhost:9555/";

function getMX() {
    var size = document.getElementById("size").value;
    if (size < 1) { document.getElementById("size").value = 1; size = 1 }
    if (size > 5) { document.getElementById("size").value = 5; size = 5 }
    for (let i = 0; i < 5; i++) {
        var idName = 'result'+i;
        document.getElementById(idName).value = '';
        document.getElementById(idName).setAttribute('style','font-size: 14px');
    }
    $.ajax({
        type: "get",
        url: urlService + '/api/mx/mayAllYourWishesComeTrue?size=' + size,
        async: true,
        success: function (res) {
            res.map(function (item, i) {
                var idName = 'result'+i;
                document.getElementById(idName).value = item;
                document.getElementById(idName).setAttribute('style','font-size: 17px');
            })
        }
    });
}

function showMX(){
    var mxHtml = '<div style="padding: 10px">';
    var isShow = false;
    for (let i = 0; i < 5; i++) {
        var idName = 'result'+i;
        var valueStr = document.getElementById(idName).value;
        if (!valueStr){
            continue;
        }
        isShow = true;
        let values = valueStr.split('-');
        var mxHtmlItem = '<div class="f_l kj_ball" id="kj_detail_result">';
        var valueLength =values.length - 1;
        values.forEach(function (item,i) {
            mxHtmlItem += i !== valueLength ? '<i>'+item.trim()+'</i>' : '<i class="blueball">'+item.trim()+'</i>';
        })
        mxHtmlItem += '<div>';
        mxHtml += mxHtmlItem;
    }
    if(!isShow)
        return;
    mxHtml += '</div>';
    var that = this;
    layer.open({
        type: 1,
        title: false,
        fixed: true,
        content: mxHtml,
        closeBtn: 0,
        shadeClose: true
    })
}

document.onkeydown = function (e) {
    var keycode = document.all ? event.keyCode : e.which;
    if (keycode == 13) {
        getMX();
    }
}